package com.woniuxy.income.web.controller;


import com.woniuxy.core.model.Result;
import com.woniuxy.core.util.JwtUtil;
import com.woniuxy.income.service.RentersIncomeService;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 凌玉春
 * @since 2024年01月15日
 */
@RestController
@RequestMapping("/rentersIncome")
public class RentersIncomeController {
    @Autowired
    private RentersIncomeService rentersIncomeService;

    @ApiOperation("业主查看今日营业收入")
    @GetMapping("/renterGetTodayInCome")
    public Result<String> renterGetTodayInCome(@RequestHeader String token){
        Claims claims = JwtUtil.parseUserToken(token);
        Integer renterId =(Integer) claims.get("id");
        String inCome=rentersIncomeService.renterGetTodayInCome(renterId);
        return Result.getResult(String.class).setMessage("业主查看今日营业收入成功").setData(inCome);
    }

    @ApiOperation("业主查看本月营业收入")
    @GetMapping("/renterGetMonthInCome")
    public Result<String> renterGetMonthInCome(@RequestHeader String token){
        Claims claims = JwtUtil.parseUserToken(token);
        Integer renterId =(Integer) claims.get("id");
        String inCome=rentersIncomeService.renterGetMonthInCome(renterId);
        return Result.getResult(String.class).setMessage("业主查看本月营业收入成功").setData(inCome);
    }

}

